﻿namespace FluentDataContract
{
    using System;
    using System.Linq.Expressions;
    using Internal;

    public abstract class AbstractDataContract<TObject> : DataContractBase, IHasAContract<IObjectContract>
    {
        private IObjectBuilder<TObject> _objectBuilder;
        private IObjectBuilder<TObject> ObjectBuilder { get { return _objectBuilder ?? (_objectBuilder = new ObjectBuilder<TObject>()); } }

        public IObjectContract Contract { get { return ObjectBuilder.Contract; } }

        public IObjectBuilder<TObject> Object()
        {
            return ObjectBuilder;
        }

        public IPropertyBuilder<TObject> Property<TProperty>(Expression<Func<TObject, TProperty>> expression)
        {
            return ObjectBuilder.Property(expression);
        }

        public IPropertyBuilder<TObject> Properties(params Expression<Func<TObject, object>>[] expressions)
        {
            return ObjectBuilder.Properties(expressions);
        }
    }
}